package main

import (
	"coolcar/initialize"
	"log"

	"go.uber.org/zap"
)

func main() {
	logger, err := newZapLogger()
	if err != nil {
		log.Fatalf("can not create logger: %v", err)
	}

	// 初始化数据库
	initialize.InitMongo(logger)

	// 初始化服务层
	initialize.InitAuthHandler(logger)
	initialize.InitRentalHandler(logger)
	initialize.InitProfileHandler(logger)

	// 初始化jwt
	initialize.InitJWT()

	// 初始化路由
	router := initialize.InitRouter()

	_ = router.Run(":8848")
}

func newZapLogger() (*zap.Logger, error) {
	cfg := zap.NewDevelopmentConfig()
	cfg.EncoderConfig.TimeKey = ""
	return cfg.Build()
}
